package org.testfire.realm.model.entities.testfire;

import java.util.Collection;
import java.util.List;
import javax.persistence.*;

/**
 * Created by IntelliJ IDEA.
 * User: granum
 * Date: Aug 26, 2007
 * Time: 2:16:11 PM
 */
@Entity
@Table(catalog = "testfire", name = "testrunnerqueue")
public class TestRunnerQueueEntity
{
    private int id;

    private int user;

    private String name;

    private String description;

    private CrontaskEntity cronTask;

    private List<TestsetEntity> testsets;

    private List<AgentEntity> agents;

    private Collection<TestsetResultEntity> testsetResults;

    private Boolean useAnyAvailableAgent;

    @OneToMany(mappedBy = "queue")
    public Collection<TestsetResultEntity> getTestsetResults()
    {
        return testsetResults;
    }

    public void setTestsetResults( Collection<TestsetResultEntity> testsetResults )
    {
        this.testsetResults = testsetResults;
    }

   
    @ManyToMany(cascade = CascadeType.REFRESH)
    @JoinTable(catalog = "testfire", name = "trqueue_owns_agents",
        joinColumns = @JoinColumn(table = "testfire.trqueue_owns_agents", name = "queue_id",
            referencedColumnName = "id", nullable = false),
        inverseJoinColumns = @JoinColumn(table = "testfire.trqueue_owns_agents", name = "agent_id",
            referencedColumnName = "id", nullable = false))
    public List<AgentEntity> getAgents()
    {
        return agents;
    }

    public void setAgents( List<AgentEntity> agents )
    {
        this.agents = agents;
    }

    @ManyToMany(cascade = CascadeType.REFRESH)
    @JoinTable(catalog = "testfire", name = "trqueue_owns_testsets",
        joinColumns = @JoinColumn(table = "testfire.trqueue_owns_testsets", name = "testrunnerqueue_id",
            referencedColumnName = "id", nullable = false),
        inverseJoinColumns = @JoinColumn(table = "testfire.trqueue_owns_testsets", name = "testset_id",
            referencedColumnName = "id", nullable = false))
    public List<TestsetEntity> getTestsets()
    {
        return testsets;
    }

    public void setTestsets( List<TestsetEntity> testsets )
    {
        this.testsets = testsets;
    }

    @OneToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "cronTask")
    public CrontaskEntity getCronTask()
    {
        return cronTask;
    }

    public void setCronTask( CrontaskEntity cronTask )
    {
        this.cronTask = cronTask;
    }

    @Basic
    @Column(name = "description", nullable = false, length = 65535)
    public String getDescription()
    {
        return description;
    }

    public void setDescription( String description )
    {
        this.description = description;
    }

    @Basic
    @Column(name = "name", nullable = false)
    public String getName()
    {
        return name;
    }

    public void setName( String name )
    {
        this.name = name;
    }

    @Basic
    @Column(name = "useanyavailableagent", nullable = false)
    public Boolean getUseAnyAvailableAgent()
    {
        return useAnyAvailableAgent;
    }

    public void setUseAnyAvailableAgent( Boolean useAnyAvailableAgent )
    {
        this.useAnyAvailableAgent = useAnyAvailableAgent;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id", nullable = false, length = 10)
    public int getId()
    {
        return id;
    }

    public void setId( int id )
    {
        this.id = id;
    }

    @Basic
    @Column(name = "user", nullable = false)
    public int getUser()
    {
        return user;
    }

    public void setUser( int user )
    {
        this.user = user;
    }


}
